import os
import shutil

def file_path(path, path_neg):
    for (root, dirs, files) in os.walk(path):
        for dirc in dirs:
            if dirc == '100w_crop_all':
                pic_path = os.path.join(root, dirc)
                for file in os.listdir(pic_path):
                    file = pic_path + '/' + file
                    print(file)
                    del_small_file(file, path_neg)


def del_small_file(file_name, path_neg):
    size = os.path.getsize(file_name)
    file_size = 0.5 *1024
    if size < file_size:
        print('remove',size,file_name)
        shutil.move(file_name, path_neg)
        #os.remove(file_name)

if __name__ == '__main__':
    path = '/home/ailab2/Documents/train_data/detection_platform_cali_100w_200w_20200914'
    path_neg = '/home/ailab2/Documents/train_data/detection_platform_cali_100w_200w_20200914/pic_neg'
    if not os.path.exists(path_neg):
        os.makedirs(path_neg)
    file_path(path, path_neg)

